#include<cstdio>//uncle-lu
#include<cmath>
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

struct node{
	long long int x, y, z;
};
node line[1010];
int n, h;
long long int r;
int Father[1010];

int Find_Father(int x)
{
	return Father[x] == x ? x : Father[x] = Find_Father(Father[x]);
}

bool dis(int x, int y)
{
	return 2*r >= sqrt((line[x].x - line[y].x) * (line[x].x - line[y].x) + (line[x].y - line[y].y) * (line[x].y - line[y].y) + (line[x].z - line[y].z) * (line[x].z - line[y].z));
}

void init()
{
	for (int i = 1; i <= n+2; i++) 
		Father[i] = i;
	return ;
}

int main()
{
	int T;
	read(T);
	for (int t = 1; t <= T; t++) 
	{
		read(n);read(h);read(r);
		init();
		for (int i = 1; i <= n; i++) 
		{
			read(line[i].x);read(line[i].y);read(line[i].z);
		}

		for (int i = 1; i <= n; i++) 
			for (int j = 1; j <= i-1; j++) 
				if(dis(i, j))
				{
					int xx = Find_Father(i), yy = Find_Father(j);
					Father[yy] = xx;
				}

		for (int i = 1; i <= n; i++) 
		{
			if(line[i].z <= r )
			{
				int xx = Find_Father(i), yy = Find_Father(n+1);
				Father[yy] = xx;
			}
			if(line[i].z + r >= h)
			{
				int xx = Find_Father(i), yy = Find_Father(n+2);
				Father[yy] = xx;
			}
		}

		int xx = Find_Father(n+1), yy = Find_Father(n+2);
		if(xx == yy)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}
